package cn.edu.cn.tomatoclock;
import androidx.appcompat.app.AppCompatActivity;
import androidx.viewpager.widget.ViewPager;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.ProgressBar;
import android.widget.TextView;

import androidx.appcompat.app.AppCompatActivity;

public class Pie extends AppCompatActivity {
    private Button btn_back;
    int completeNum = 7;
    int allNum = 10;

    protected void onCreate(Bundle TomatoClock) {
        super.onCreate(TomatoClock);
        setContentView(R.layout.piechart);
        updateChart();
        btn_back = (Button) findViewById(R.id.btn_Back);
        btn_back.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                //設定按下之後要執行的Activity
                Intent intent = new Intent(Pie.this, MainActivity.class);
                startActivity(intent);
            }
        });
    }

    public void updateChart(){
        //update the text in the center of pie chart
        TextView numberOfCom = findViewById(R.id.number_of_calories);
        numberOfCom.setText(completeNum + " / " + allNum);

        // Calculate the slice size and update the pie chart:
        ProgressBar pieChart = findViewById(R.id.stats_progressbar);
        double d = (double) completeNum / (double) allNum;
        int progress = (int) (d * 100);
        pieChart.setProgress(progress);

    }


}
